﻿using System;
using System.Collections.Generic;
using System.Text;
using Vortex.Wrapper.Platform;

namespace Vortex.Input {

	///<summary>Key states - combination of flags representing which key controls were down when event occurred. It is analog of ModifierKeys from Syste.Windows.Input</summary>
	[Flags]
	public enum KeyStates : ushort {
		None = 0,
		///<summary>Control was down when some action occurred</summary>
		Control = MK.CONTROL,
		///<summary>Shift was down when some action occurred</summary>
		Shift = MK.SHIFT,
		///<summary>Alt was down when some action occurred. Note. This flag is invalid when receiving events from IMouse/IKeyboard because of operating system limitations</summary>
		Alt = 32,
		///<summary>Left mouse button was down when some action occurred</summary>
		LeftButton = MK.LBUTTON,
		///<summary>Right mouse button was down when some action occurred</summary>
		RightButton = MK.RBUTTON,
		///<summary>Middle mouse button was down when some action occurred</summary>
		MiddleButton = MK.MBUTTON
	};

	///<summary>Simple mouse button enumeration.</summary>
	public enum MouseButton {
		///<summary>Undefined mouse button</summary>
		None = 0,
		///<summary>Left mouse button</summary>
		Left = 1,
		///<summary>Right mouse button</summary>
		Right = 2,
		///<summary>Middle mouse button</summary>
		Middle = 3
	};

	///<summary>Mouse button states represented as flags</summary>
	[Flags]
	public enum MouseButtons {
		///<summary>No mouse buttons are selected</summary>
		None = 0,
		///<summary>Left mouse button is triggered</summary>
		Left = 1,
		///<summary>Right mouse button is triggered</summary>
		Right = 2,
		///<summary>Middle mouse button is triggered</summary>
		Middle = 4
	};

	///<summary>Mouse events enumeration</summary>
	public enum MouseAction {
		///<summary>Defines an action on mouse pointer is moved</summary>
		Move,
		///<summary>Defines an action on mouse button is up</summary>
		Up,
		///<summary>Defines an action on mouse button is down</summary>
		Down,
		///<summary>Defines an action on mouse click happened (down, up at the same point)</summary>
		Click,
		///<summary>Defines an action on mouse double clicked was triggered</summary>
		DoubleClick,
		///<summary>Defines an action when mouse pointer was moved inside some region</summary>
		Over,
		///<summary>Defines an action when mouse pointer was moved outside some region</summary>
		Out
	};
	
	///<summary>Enumerates all possible keyboard keys for async input</summary>
	public enum Key : byte {
		Escape          = 0x01,
		D1              = 0x02,
		D2              = 0x03,
		D3              = 0x04,
		D4              = 0x05,
		D5              = 0x06,
		D6              = 0x07,
		D7              = 0x08,
		D8              = 0x09,
		D9              = 0x0A,
		D0              = 0x0B,
		Minus           = 0x0C,   /* - on main keyboard */
		Equals          = 0x0D,
		BackSpace       = 0x0E,    /* backspace */
		Tab             = 0x0F,
		Q               = 0x10,
		W               = 0x11,
		E               = 0x12,
		R               = 0x13,
		T               = 0x14,
		Y               = 0x15,
		U               = 0x16,
		I               = 0x17,
		O               = 0x18,
		P               = 0x19,
		LeftBracket     = 0x1A,
		RightBracket    = 0x1B,
		Return          = 0x1C,    /* Enter on main keyboard */
		LeftControl     = 0x1D,
		A               = 0x1E,
		S               = 0x1F,
		D               = 0x20,
		F               = 0x21,
		G               = 0x22,
		H               = 0x23,
		J               = 0x24,
		K               = 0x25,
		L               = 0x26,
		Semicolon       = 0x27,
		Apostrophe      = 0x28,
		Grave           = 0x29,    /* accent grave */
		LeftShift       = 0x2A,
		BackSlash       = 0x2B,
		Z               = 0x2C,
		X               = 0x2D,
		C               = 0x2E,
		V               = 0x2F,
		B               = 0x30,
		N               = 0x31,
		M               = 0x32,
		Comma           = 0x33,
		Period          = 0x34,    /* . on main keyboard */
		Slash           = 0x35,    /* / on main keyboard */
		RightShift      = 0x36,
		NumpadMultiply  = 0x37,    /* * on numeric keypad */
		LeftAlt         = 0x38,   /* left Alt */
		Space           = 0x39,
		CapsLock        = 0x3A,
		F1              = 0x3B,
		F2              = 0x3C,
		F3              = 0x3D,
		F4              = 0x3E,
		F5              = 0x3F,
		F6              = 0x40,
		F7              = 0x41,
		F8              = 0x42,
		F9              = 0x43,
		F10             = 0x44,
		NumLock         = 0x45,
		ScrollLock      = 0x46,    /* Scroll Lock */
		Numpad7         = 0x47,
		Numpad8         = 0x48,
		Numpad9         = 0x49,
		NumpadMinus     = 0x4A,   /* - on numeric keypad */
		Numpad4         = 0x4B,
		Numpad5         = 0x4C,
		Numpad6         = 0x4D,
		NumpadAdd       = 0x4E,    /* + on numeric keypad */
		Numpad1         = 0x4F,
		Numpad2         = 0x50,
		Numpad3         = 0x51,
		Numpad0         = 0x52,
		NumpadDecimal   = 0x53,    /* . on numeric keypad */
		OEM_102         = 0x56,    /* <> or \| on RT 102-key keyboard (Non-U.S.) */
		F11             = 0x57,
		F12             = 0x58,
		F13             = 0x64,    /*                     (NEC PC98) */
		F14             = 0x65,    /*                     (NEC PC98) */
		F15             = 0x66,    /*                     (NEC PC98) */
		Kana            = 0x70,    /* (Japanese keyboard)            */
		ABNT_C1         = 0x73,    /* /? on Brazilian keyboard */
		Convert         = 0x79,    /* (Japanese keyboard)            */
		NoConvert       = 0x7B,    /* (Japanese keyboard)            */
		Yen             = 0x7D,    /* (Japanese keyboard)            */
		ABNT_C2         = 0x7E,    /* Numpad . on Brazilian keyboard */
		NumpadEquals    = 0x8D,    /* = on numeric keypad (NEC PC98) */
		PrevTrack       = 0x90,    /* Previous Track (CIRCUMFLEX on Japanese keyboard) */
		At              = 0x91,    /*                     (NEC PC98) */
		Colon           = 0x92,    /*                     (NEC PC98) */
		Underline       = 0x93,    /*                     (NEC PC98) */
		Kanji           = 0x94,    /* (Japanese keyboard)            */
		Stop            = 0x95,    /*                     (NEC PC98) */
		Ax              = 0x96,    /*                     (Japan AX) */
		Unlabeled       = 0x97,    /*                        (J3100) */
		NextTrack       = 0x99,    /* Next Track */
		NumpadEnter     = 0x9C,    /* Enter on numeric keypad */
		RightControl    = 0x9D,
		Mute            = 0xA0,    /* Mute */
		Calculator      = 0xA1,    /* Calculator */
		PlayPause       = 0xA2,    /* Play / Pause */
		MediaStop       = 0xA4,    /* Media Stop */
		VolumeDown      = 0xAE,    /* Volume - */
		VolumeUp        = 0xB0,    /* Volume + */
		WebHome         = 0xB2,    /* Web home */
		NumpadComma     = 0xB3,    /* , on numeric keypad (NEC PC98) */
		NumpadDivide    = 0xB5,    /* / on numeric keypad */
		SysRQ           = 0xB7,
		RightAlt        = 0xB8,    /* right Alt */
		Pause           = 0xC5,    /* Pause */
		Home            = 0xC7,    /* Home on arrow keypad */
		Up              = 0xC8,    /* UpArrow on arrow keypad */
		PageUp          = 0xC9,    /* PgUp on arrow keypad */
		Left            = 0xCB,    /* LeftArrow on arrow keypad */
		Right           = 0xCD,    /* RightArrow on arrow keypad */
		End             = 0xCF,    /* End on arrow keypad */
		Down            = 0xD0,    /* DownArrow on arrow keypad */
		PageDown        = 0xD1,    /* PgDn on arrow keypad */
		Insert          = 0xD2,    /* Insert on arrow keypad */
		Delete          = 0xD3,    /* Delete on arrow keypad */
		LeftWin         = 0xDB,    /* Left Windows key */
		RightWin        = 0xDC,    /* Right Windows key */
		Apps            = 0xDD,    /* AppMenu key */
		Power           = 0xDE,    /* System Power */
		Sleep           = 0xDF,    /* System Sleep */
		Wake            = 0xE3,    /* System Wake */
		WebSearch       = 0xE5,    /* Web Search */
		WebFavourites   = 0xE6,    /* Web Favorites */
		WebRefresh      = 0xE7,    /* Web Refresh */
		WebStop         = 0xE8,    /* Web Stop */
		WebForward      = 0xE9,    /* Web Forward */
		WebBack         = 0xEA,    /* Web Back */
		MyComputer      = 0xEB,    /* My Computer */
		Mail            = 0xEC,    /* Mail */
		MediaSelect     = 0xED    /* Media Select */
	};

	///<summary>Enumerates all of possible virtual keyboard keys defined for Windows OS</summary>
	public enum VirtualKey : uint {
		None = 0,
		Backspace = VK.BACK,
		Tab = VK.TAB,
		Clear = VK.CLEAR,
		Shift = VK.SHIFT,
		Control = VK.CONTROL,
		Menu = VK.MENU,
		Pause = VK.PAUSE,
		CapsLock = VK.CAPITAL,
		Escape = VK.ESCAPE,
		Space = VK.SPACE,
		PageUp = VK.PRIOR,
		PageDown = VK.NEXT,
		End = VK.END,
		Home = VK.HOME,
		Left = VK.LEFT,
		Up = VK.UP,
		Right = VK.RIGHT,
		Down = VK.DOWN,
		Select = VK.SELECT,
		Print = VK.PRINT,
		Execute = VK.EXECUTE,
		Snapshot = VK.SNAPSHOT,
		Insert = VK.INSERT,
		Delete = VK.DEL,
		Help = VK.HELP,
		LeftWin = VK.LWIN,
		RightWin = VK.RWIN,
		Apps = VK.APPS,
		Sleep = VK.SLEEP,
		Numpad0 = VK.NUMPAD0,
		Numpad1 = VK.NUMPAD1,
		Numpad2 = VK.NUMPAD2,
		Numpad3 = VK.NUMPAD3,
		Numpad4 = VK.NUMPAD4,
		Numpad5 = VK.NUMPAD5,
		Numpad6 = VK.NUMPAD6,
		Numpad7 = VK.NUMPAD7,
		Numpad8 = VK.NUMPAD8,
		Numpad9 = VK.NUMPAD9,
		NumpadMultiply = VK.MULTIPLY,
		NumpadAdd = VK.ADD,
		NumpadSeparator = VK.SEPARATOR,
		NumpadSubtract = VK.SUBTRACT,
		NumpadDecimal = VK.DECIMAL,
		NumpadDivide = VK.DIVIDE,
		F1 = VK.F1,
		F2 = VK.F2,
		F3 = VK.F3,
		F4 = VK.F4,
		F5 = VK.F5,
		F6 = VK.F6,
		F7 = VK.F7,
		F8 = VK.F8,
		F9 = VK.F9,
		F10 = VK.F10,
		F11 = VK.F11,
		F12 = VK.F12,
		NumLock = VK.NUMLOCK,
		Scroll = VK.SCROLL,
		LeftShift = VK.LSHIFT,
		RightShift = VK.RSHIFT,
		LeftControl = VK.LCONTROL,
		RightControl = VK.RCONTROL,
		LeftAlt = VK.LMENU,
		RightAlt = VK.RMENU,

		/* generic number buttons */

		D0 = '0',
		D1 = '1',
		D2 = '2',
		D3 = '3',
		D4 = '4',
		D5 = '5',
		D6 = '6',
		D7 = '7',
		D8 = '8',
		D9 = '9',

		/* generic letter buttons */

		A = 'A',
		B = 'B',
		C = 'C',
		D = 'D',
		E = 'E',
		F = 'F',
		G = 'G',
		H = 'H',
		I = 'I',
		J = 'J',
		K = 'K',
		L = 'L',
		M = 'M',
		N = 'N',
		O = 'O',
		P = 'P',
		Q = 'Q',
		R = 'R',
		S = 'S',
		T = 'T',
		U = 'U',
		V = 'V',
		W = 'W',
		X = 'X',
		Y = 'Y',
		Z = 'Z'
	};
}
